/***********************************************
 * Author:Mike Truong
 * Date: 7/19/2014 11:54 AM
 * Description: Random Test for Adventurer Card
 ***********************************************/

#include "dominion.h" 
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

int check_adventurer(struct gamestate *state)
{
	int card = adventurer;
	int choice1 = 0; 
	int choice2 = 0;
	int choice3 = 0;
	int hp = 0;
	int bonus = 0; 
	int result = 0; 

	state->whoseTurn = 1;
	state->numPlayers = 3;
	
	for(choice1=0; choice1 < 4; choice1++){
		for (choice2 = 0; choice2 < 4; choice2++){
			for (choice3 = 0; choice3 < 4; choice3++){
				for (hP = 0; hP < 4; hP++){
					cardEffect(card,choice1,choice2,choice3,state,hP,&bonus);
					assert(result == 0);
				}
			}	
	
		}
	}
	return 0;
}	

int main()
{
	int i,n,p;
	//int handPos;
	int k[10] = { adventurer, council_room, feast, gardens, mine, remodel, smithy, village, baron, great_hall};

	struct gameState G;
	printf("Adventurer Random Test Begins:.\n");

	SelectStream(2);
	PutSeed(3);

	for( n = 0; n < 800; n++){
		for(i = 0; i < sizeof(struct gameState); i++){
			((char*)&G)[i] = floor(Random() * 256);
		}
		p = 4;
		int r = initializeGame(p,k,1,&G);
		if( r !=0)
			printf("Failed to initialize game state ! \n");
		int currPlayer = floor(Random()*p);
		G.whoseTurn = currPlayer;
		G.deckCount[currPlayer] = floor(Random() * MAX_DECK);
		G.discardCount[currPlayer] = floor(Random() * MAX_DECK);
		G.handCount[currPlayer] = floor(Random() * MAX_HAND);

		//Fill hand, deck, and discard with random cards
		for(i = 0; i < G.handCount[currPlayer]; i++){
			int card = floor(Random() * 17);
			if(card < 7)
				G.hand[currPlayer][i] = card;
			else
				G.hand[currPlayer][i] = k[card - 7];
		}
		for(i = 0; i < G.deckCount[currPlayer]; i++){
			int card = floor(Random() *17);
			if (card < 7 )
				G.deck[currPlayer][i] = card;
			else
				G.deck[currPlayer][i] = k[card - 7];
		}
		for( i = 0; i < G.discardCount[currPlayer]; i++){
			int card = floor(Random() * 17);
			if (card < 7)
				G.discard[currPlayer][i] = card;
			else
				G.discard[currPlayer][i] = k[card - 7];
		}
		check_adventurer(&G);
	}
	return 0;
}	







































